//
//  FindCell.m
//  FD
//
//  Created by Yasin on 2018/10/10.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "FindCell.h"
@interface FindCell()

@property (weak, nonatomic) IBOutlet UILabel *typeLb; //隐藏不用

@property (weak, nonatomic) IBOutlet UIImageView *iconIV; //图标
@property (weak, nonatomic) IBOutlet UILabel *nameLb; //标题
@property (weak, nonatomic) IBOutlet UILabel *timeLb; //有效期
@property (weak, nonatomic) IBOutlet UIButton *obtainNowBtn; //立即领取按钮


@end

@implementation FindCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    //隐藏
    self.typeLb.hidden = YES;

    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setFindModel:(FindModel *)findModel {
    _findModel = findModel;
    
    //设置数据
    [self.iconIV sd_setImageWithURL:[NSURL URLWithString:findModel.thumbnail] placeholderImage:[UIImage imageNamed:@"1"]];
    
    self.nameLb.text = findModel.title;
    self.timeLb.text = [NSString stringWithFormat:@"有效期:%@至%@",findModel.beginTimeStr,findModel.endTimeStr];
    

    //修改按钮的状态
    if (findModel.isReceive) { //已领取
        [self.obtainNowBtn setTitle:@"已经领" forState:(UIControlStateNormal)];
        //修改文字和背景颜色字
        self.obtainNowBtn.backgroundColor = [UIColor lightGrayColor];
        
        //按钮不可点
        self.obtainNowBtn.userInteractionEnabled = NO;
    }else { //为领取点击领取
        
        [self.obtainNowBtn setTitle:NSLocalizedString(L_LingQuYouHuiQuan, @"领取优惠券") forState:(UIControlStateNormal)];
        //修背景颜色字
        self.obtainNowBtn.backgroundColor = [UIColor redColor];
        //按钮不可点
        self.obtainNowBtn.userInteractionEnabled = YES;
    }
}


//!!!!:领取优惠券事件
- (IBAction)clickObtainCouponAction:(UIButton *)sender {
    
    if (self.clickObtainCouponBlock) { //把自己传递出去
        self.clickObtainCouponBlock();
    }
}



@end
